#!/bin/bash
#如何检测特定的服务是不是挂了并拉起特定的服务
var1=$$

function main
{
    ps -ef|grep mysql|grep -v grep|grep -v $var1 &> /dev/null
    if [ $? -eq 0 ]; then
        return 0
    else
        systemctl restart mysql
        echo "mysql is not running"
        return 1
    fi
}

main && echo "func is running" || echo  "func is not running"